package com.forstudy.util;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * @ProjectName: Doctor
 * @Package: com.doctor.http
 * @ClassName: NetUtils
 * @Author: ErDong
 * @CreateDate: 2020/4/5 16:35
 * @UpdateUser: ErDong
 * @UpdateDate: 2020/4/5 16:35
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class NetUtils {

    private static OkHttpClient client = new OkHttpClient();
    private static Request.Builder builder;

    public static void request(String url) {

        builder = new Request.Builder().url(url);
        Request request = builder.build();
        System.out.println("Running");
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                System.out.println("Failed");
                System.out.println(e.getMessage());
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                System.out.println("Success");
                System.out.println(response.body().string());
            }
        });
    }
}
